home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
A.D. Software
/
OOFGraph
/
Application Source
/
StackedBarGraphWindow.cp
< prev
next >
Wrap
Text File
|
1996-06-15
|
3KB
|
111 lines
// ===========================================================================
// StackedBarGraphWindow.cp
// ===========================================================================
//
#include "StackedBarGraphWindow.h"
#include <LApplication.h>
#include <LGrowZone.h>
#include <LWindow.h>
#include <UDrawingState.h>
#include <UMemoryMgr.h>
#include <URegistrar.h>
#include "oofDrawStyleSet.h"
#define WIND_Graph 201
#define PANE_Plot 301
// ---------------------------------------------------------------------------
// • StackedBarGraphWindow
// ---------------------------------------------------------------------------
// Constructor
StackedBarGraphWindow::StackedBarGraphWindow(LCommander* inSuperCommander, dbView *theView, StringPtr theTitle,
unsigned long xAxisLength)
{
// Make a window
mDisplayWindow = LWindow::CreateWindow(WIND_Graph, inSuperCommander);
//let's find our WASTE pane..
CPlotPane *PlotView = (CPlotPane *) mDisplayWindow->FindPaneByID(PANE_Plot);
Rect theFrame;
PlotView->CalcLocalFrameRect( theFrame );
oofColor theColor(4474,3442,53247);
mDisplayWindow->FocusDraw();
short fontNum;
::GetFNum("\pPalatino",&fontNum); // Get my favourite font :)
if(fontNum==0)
::TextFont(1);
else
::TextFont(fontNum);
mBarGraphPtr = new oofStackedBarGraph(theFrame,theColor,theView,theTitle,xAxisLength);
mBarGraphPtr->setDrawStyleSet(oofDrawStyleSetDefaultIteration());
PlotView->SetGraph(mBarGraphPtr);
mDisplayWindow->Show();
}
// ---------------------------------------------------------------------------
// • ~StackedBarGraphWindow
// ---------------------------------------------------------------------------
// Destructor
StackedBarGraphWindow::~StackedBarGraphWindow()
{
delete mDisplayWindow;
}
// Register the functions to create our custom Pane classes
void
StackedBarGraphWindow::RegisterClass()
{
URegistrar::RegisterClass(LWindow::class_ID, (ClassCreatorFunc)LWindow::CreateWindowStream);
URegistrar::RegisterClass(CPlotPane::class_ID,(ClassCreatorFunc)CPlotPane::CreatePlotPaneStream);
URegistrar::RegisterClass(LPrintout::class_ID, (ClassCreatorFunc)LPrintout::CreatePrintoutStream);
URegistrar::RegisterClass(LPlaceHolder::class_ID, (ClassCreatorFunc)LPlaceHolder::CreatePlaceHolderStream);
}
//-- Printing Stuff--
#define Prto_PictText 901 // Printout for printing the scrolling view
#define place_PictText 911 // Placeholder for the main body
void
StackedBarGraphWindow::DoPrinting()
{
// set graph to mono
mBarGraphPtr->setStyleToMono();
// Read the Printout resource and find the place
// holders for the scrolling view.
LPrintout *thePrintout = LPrintout::CreatePrintout(Prto_PictText);
LPlaceHolder *thePlace = (LPlaceHolder*) thePrintout->FindPaneByID(place_PictText);
// Now find the view in this window
// and install it into its place holder.
LView *theView = (LView *) mDisplayWindow->FindPaneByID(PANE_Plot);
thePlace->InstallOccupant(theView, kAlignAbsoluteCenter);
// This is the function that starts the printing.
thePrintout->DoPrintJob();
// The Printout's destructor takes care of setting the
// views back to where they came from.
delete thePrintout;
mBarGraphPtr->setStyleToColor();
}